﻿using System;
using Framework.Poco;
using Shell.DomainDot;

namespace Framework.Domain
{
    /// <summary>
    /// 经销商文章创建器
    /// </summary>
    public class CreateAgencyArticle : DomainDotBase<Agency>
    {
        /// <summary>
        /// 经销商的文章
        /// </summary>
        public WithMany<Article> Articles { get; set; }

        /// <summary>
        /// 创建文章
        /// </summary>
        public void Create(Article instance)
        {
            instance.Created = DateTime.Now;
            instance.Author = this.Instance.DisplayName;
            var entity = this.Articles.Create();
            PocoUtils.AssignProperty<Article>(instance, entity, typeof(Guid));
            this.Articles.Submit();
        }
    }
}
